package com.javasm.transfer.orderTransfer;

import com.javasm.domin.entity.orderEntity.B2cOrder;
import com.javasm.domin.entity.orderEntity.B2cOrderExcel;
import com.javasm.domin.entity.orderEntity.B2cReceiver;
import com.javasm.domin.vo.orderVo.OrderAndReceiver;
import com.javasm.mapper.B2cOrderMapper.B2cDataDictionaryMapper;
import com.javasm.mapper.B2cOrderMapper.B2cReceiverMapper;
import com.javasm.mapper.B2cOrderMapper.ReturnGoodsMapper;
import com.javasm.transfer.base.BaseTransfer;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

import static com.javasm.common.dictionary.InitContext.dic;

/**
 * @Author：liyangsong
 * @Version：1.0
 * @Date：2021/11/29-15:28
 * @Since:jdk1.8
 * @Description:
 */

@Component
public class OrderExcelTransfer extends BaseTransfer<B2cOrder, B2cOrderExcel> {
    @Resource
    private B2cDataDictionaryMapper b2cDataDictionaryMapper;
    @Resource
    private ReturnGoodsMapper returnGoodsMapper;
    @Resource
    private B2cReceiverMapper b2cReceiverMapper;

    //1.订单动作 2 订单状态 3 业务类型 4 配送方式  5 支付方式  6订单分类订单类型 ',
    public List<B2cOrderExcel> Escape(List<B2cOrder> b2cOrderList) {
        List<B2cOrderExcel> b2cOrderExcels = super.toVO(b2cOrderList);
//        List<B2cReceiver> b2cReceivers = b2cReceiverMapper.selectList(null);
        for (int i = 0; i < b2cOrderExcels.size(); i++) {
            B2cOrder b2cOrder = b2cOrderList.get(i);
            B2cOrderExcel b2cOrderExcel = b2cOrderExcels.get(i);
            b2cOrderExcel.setOrderAction(dic.get(1).get(b2cOrder.getOrderAction()));
            b2cOrderExcel.setOrderStatus(dic.get(2).get(b2cOrder.getOrderStatus()));
            b2cOrderExcel.setBusinessType(dic.get(3).get(b2cOrder.getBusinessType()));
            b2cOrderExcel.setDeliveryStyle(dic.get(4).get(b2cOrder.getDeliveryStyle()));
            b2cOrderExcel.setPaymentMethodId(dic.get(5).get(b2cOrder.getPaymentMethodId()));
            b2cOrderExcel.setOrderType(dic.get(6).get(b2cOrder.getOrderType()));
            if (b2cOrder.getDeliveryInsurance() == 1){
                b2cOrderExcel.setDeliveryInsurance("是");
            }else {
                b2cOrderExcel.setDeliveryInsurance("否");
            }
            if (b2cOrder.getDeliverySamecity() == 1){
                b2cOrderExcel.setDeliverySamecity("是");
            }else {
                b2cOrderExcel.setDeliverySamecity("否");
            }

        }
        return b2cOrderExcels;
    }
}
